<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>


    <script type="text/javascript">
        $(function () {

            $('#pagination').twbsPagination({
                        totalPages:${result.pages} || 1,
                    startPage
            :${result.pageNum},
            visiblePages:${result.pageSize},
            first:"首页",
                    prev
            :
            "上页",
                    next
            :
            "下页",
                    last
            :
            "尾页",
                    //event 表示事件对象
                    //page 表示页码: 当前页
                    onPageClick
            :
            function (event, page) {
                //讲当前页设置page值
                $("#currentPage").val(page);
                //表单提交gjk,mb/.
                $("#searchForm").submit();
            }
        })
            ;
            //修改按钮
            $(".editBtn").click(function () {
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                $("#travelCommendId").val(json.id);

                $("#title").val(json.title);
                $("#subTitle").val(json.subTitle);
                $("#schedule").val(json.schedule);
                $("#type").val(json.type);
                //封面
                $("#coverImg").attr('src', json.coverUrl);
                $("#coverUrl").val(json.coverUrl);
                //修改a链接(游记)的地址
                $("#skip").attr('href', "/travelRelease/list.do?travelId=" + json.travelId);
                $("#commendModal").modal('show');
            })
            //保存按钮
            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    showMessager(data);
                })
            })

        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记推荐列表</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelCommend/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输游记标题">
                </div>
                <div class="form-group">
                    <label for="state">类型:</label>
                    <select class="form-control" id="type" name="type">
                        <option value="-1">全部</option>
                        <option value="1">每月推荐</option>
                        <option value="2">每周推荐</option>
                        <option value="3">攻略推荐</option>
                    </select>
                    <script>
                        $('#type option-[value' + '${qo.type}' + ']').prop('selected', true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">查询</button>

            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>封面</th>
                    <th>标题</th>
                    <th>副标题</th>
                    <th>推荐时间</th>
                    <th>推荐类型</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td><img src="${(entity.coverUrl)!}" width="50px"/></td>
                    <td>${(entity.title)!}</td>
                    <td>${(entity.subTitle)!}</td>
                    <td>${((entity.schedule)?string("yyyy-MM-dd"))!}</td>
                    <td>
                        <#if entity.type==1>
                            每周推荐
                        <#elseif entity.type==2>
                            每月推荐
                        <#elseif entity.type==3>
                            攻略推荐

                        </#if>
                    </td>
                    <td><a href="javascript:void(0);" class="editBtn" data-json='${entity.jsonString}'>修改</a></td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<#include "../travel/editModal.ftl">


</body>
</html>